package src.Thirteen;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyJDialog extends JDialog {

    public class DialogDemo extends JFrame{
        public void init(){
            this.setVisible(true);
            this.setSize(700,500);
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

            Container container = this.getContentPane();
            //绝对布局
            container.setLayout(null);

            JButton jButton = new JButton("弹出一个弹窗");
            jButton.setBounds(300,300,200,50);

            jButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    new MyDialogDemo ();
                }
            });
            container.add(jButton);

            JButton jButton1 = new JButton("禁止改变窗体的大小");
            jButton1.setBounds(100,100,200,50);
            jButton1.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    setResizable(false);
                }
            });

            container.add(jButton1);
        }
    }
    class MyDialogDemo  extends JDialog{
        public MyDialogDemo (){
            this.setVisible(true);
            this.setBounds(100,100,500,500);
            Container container = this.getContentPane();
            container.setLayout(null);
            JLabel jLabel = new JLabel("飞飞带你飞");
            jLabel.setBounds(100,100,100,100);
            container.add(jLabel);
            this.setResizable(false);
        }
    }

    public void test(){
        new DialogDemo().init();
    }


    public static void main(String[] args) {
        MyJDialog myJDialog = new MyJDialog();
        myJDialog.test();
    }

}
